﻿<UserControl x:Class="ImageGallery.Control.ImageControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30*" />
            <RowDefinition Height="20" />
            <RowDefinition Height="70*" />
        </Grid.RowDefinitions>
        <ScrollViewer Grid.Row="0">
            <ItemsControl ItemsSource="{Binding Images}" >
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Border BorderThickness="3" Margin="10" x:Name="border" Background="White" MouseDown="border_MouseDown_1">
                                <Image Source="{Binding ImageUri}" Height="100" Width="100" />
                                <Border.Style>
                                    <Style TargetType="Border">
                                        <Setter Property="BorderBrush" Value="Black" />
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ElementName=border, Path=IsMouseOver}" Value="True">
                                                <Setter Property="BorderBrush" Value="Red"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Border.Style>
                            </Border>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </ScrollViewer>
        <Border BorderBrush="Black" BorderThickness="3" Grid.Row="2">
            <Image Source="{Binding SelectedImage.ImageUri}" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>
    </Grid>
</UserControl>
